IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'VW_CreditFetch')
	BEGIN
		DROP  View VW_CreditFetch
	END
GO

CREATE View VW_CreditFetch AS

SELECT
	c.CreditId, c.AccountId, c.Amount, c.Reference, c.Details,
	c.CreditDate, c.CreateDate, c.UpdateDate, 
	a.Code AS AccountCode, a.Title AS AccountTitle
FROM Credits AS c
INNER JOIN Accounts AS a ON a.AccountId = c.AccountId

GO